const App = getApp();
// 工具类
import Util from '../../../utils/util.js';
// 富文本插件
import wxParse from '../../../wxParse/wxParse.js';
Page({
  /**
   * 页面的初始数据
   */
  data: {
    isLogin: false,
    teamId: 0,
    team_id: 0,
    cate:1,    //1供应，2需求
    detail:{},
    supply:[], //供应list
    demand:[], //需求list
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
     //设置页面标题
     wx.setNavigationBarTitle({
      title: App.getConfig().team.detail
    })
    this.setData({
      team_id: options.nid
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    let _this = this;
    _this.setData({
      isLogin: App.checkIsLogin(),
    });
    if (_this.data.isLogin) {
      //获取服务队
      _this.setData({
        teamId: App.checkTeam()
      });
      // 获取数据
      this.getData();
    }
  },
  // 获取数据
  getData(e){
    let that = this;
    App._get('team/detail', {team_id:that.data.team_id}, result => {
       // 富文本转码
      if (result.data.detail.team_leader.length > 0) {
        wxParse.wxParse('content', 'html', result.data.detail.team_leader, that, 0);
      }
      that.setData({
        detail: result.data.detail
      }); 
    });
  },
  // tab切换
  onChangeNews(e){
    let that = this;
    that.setData({
      cate: e.currentTarget.dataset.id
    }); 
    that.getData();
  },
  //显示图片
  showImage(e){
    
  },
  /**
  * 分享当前页面
  */
  onShareAppMessage() {
    return {
      title: this.data.detail.team_name,
      path: "pages/team/detail/index?nid="+this.data.team_id
    };
  },
  /**
   * 分享到朋友圈
   */
  onShareTimeline() {
    return {
      title: this.data.detail.team_name,
      path: "pages/team/detail/index?nid="+this.data.team_id
    };
  },

})